<?php
class shouye extends top
{
	//重定义构造函数
    function __construct(){  
        parent::__construct();
        //定义当前导航
        $this->nav_name = 'shouye';
        $this->page_title = '首页信息管理';
        $this->breadcrumb += array('1'=>array('name'=>'首页','url'=>spUrl('shouye')));

    }
	function index(){
		$data = $this->spArgs();
		$shouye_class = spClass('m_shouye');
		//var_dump($data);
		//var_dump($_FILES);
		if( isset($data['description']) ){ 
			$temp_id = $data['pic_id'];
			$shouye_class->update(array('id'=>$temp_id),array('description'=>$data['description']));
		}

		if( isset($data['pic_src_update']) ){ 
			$temp_id = $data['pic_id'];
			$pic_files = $_FILES;
			$new_file_src= time().substr($_FILES['pic_src']['name'], strpos($_FILES['photo']['name'],'.'));
			$new_file_src_string = '../tpl/images/'.$new_file_src; 
			//var_dump($new_file_src_string);
			$www_dir = substr($_SERVER['SCRIPT_FILENAME'],0,-15);
			$new_www_dir = $www_dir.'tpl/images/'.$new_file_src;
			//var_dump($new_www_dir);
			move_uploaded_file($pic_files['pic_src']['tmp_name'], iconv("utf-8","gbk", $new_www_dir) );
			$shouye_class->update(array('id'=>$temp_id),array('src'=>$new_file_src_string));
			//$shouye_class->update(array('id'=>$temp_id),array('description'=>$data['description']));
		}

		if( isset($data['pic_url_update']) ){ 
			$temp_id = $data['pic_id'];
			$temp_url = $data['url'];
			$shouye_class->update(array('id'=>$temp_id),array('url'=>$temp_url));
		}

		$all_pic = $shouye_class->findAll();
		$this->all_pic = $all_pic;
		//var_dump($this->all_pic);
		$this->c = 'shouye';
		$this->a = 'index';		
		$this->data_return = $data;
		//var_dump($this->member_result);	
	}

	function edit(){
		$member = spClass('m_member');
		$data = $this->spArgs();

		if( isset($data['member_id']) ){
			$target_member = $member->find(array('id' => $data['member_id']) );
			$this->target_member_result = $target_member;
			$this->c = 'check';
			$this->a = 'edit';
			$this->data_return = $data;
		}
		if( isset($data['is_edit_submit']) && isset($data['change_do']) ){
			$change_arr = array(
				'name' => $data['change_name'],
				'phone' => $data['change_phone'],
				'unit' => $data['change_unit'],
				'email' => $data['change_email'],
				'intro' => $data['change_intro'],
				);
			$member->update('id='.$data['change_id'],$change_arr);
			
			$this->jump(spUrl('check','index'));
		}
	}

}